﻿using System;
using System.Data.SqlClient;
using InvestmentIntelligence.DbModel.Models;

namespace InvestmentIntelligence.Data.Repository.EFImplementation
{
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Linq;

    public class TradeConsistencyCheckRepository : IIPRepository<TradeConsistencyCheck>, ITradeConsistencyCheckRepository
    {
      

        public void RemoveByBookDate(int bookId, DateTime startDate, DateTime? endDate = null)
        {
            endDate = endDate ?? DateTime.MaxValue;
            ExecuteSqlCommand(DB.SqlCommandBuilder.ComposeDelete(GetTableName(),
                                                                               "FundBookEntityId = @FundBookEntityId and [Date]>=@StartDate  and [Date]<=@EndDate"),
                                            new SqlParameter("@FundBookEntityId", bookId), new SqlParameter("@StartDate", startDate), new SqlParameter("@EndDate", endDate));
        }

        public new List<T> GetList<T>(Func<IQueryable<TradeConsistencyCheck>, IEnumerable<T>> f)
        {
            return GetList(dc => f(dc.Include("FundBookEntity.Fund").Include("Security")));
        }

        
    }
}
